﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LAN_Party_Manager
{
    public partial class frmActive : Form
    {
        public frmActive()
        {
            InitializeComponent();
        }

        private void frmActive_Load(object sender, EventArgs e)
        {
            lstAll.Items.Clear();
            lstActive.Items.Clear();
            if (Player.players.Count > 0)
                foreach (Player p in Player.players)
                {
                    if(!p.isActive())
                        lstAll.Items.Add(p.getName());
                }
            updateList();
        }
        private void updateList()
        {
            lstActive.Items.Clear();
            if (Player.players.Count > 0)
                foreach (Player p in Player.players)
                    if(p.isActive())
                        lstActive.Items.Add(p.getName());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            foreach (Player t in Player.players)
            {
                if (t.getName() == lstAll.GetItemText(lstAll.SelectedItem))
                {
                    t.setActive();
                    lstActive.Items.Add(t.getName());
                    break;
                }
            }
            lstAll.Items.Remove(lstAll.SelectedItem);
        }

        private void makeInactive_Click(object sender, EventArgs e)
        {
            foreach (Player t in Player.players)
            {
                if (t.getName() == lstActive.GetItemText(lstActive.SelectedItem))
                {
                    t.setInactive();
                    lstAll.Items.Add(t.getName());
                    break;
                }
            }
            lstActive.Items.Remove(lstActive.SelectedItem);
        }
    }
}
